﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MudEngine.Parsing.AST
{
    public class FieldDeclaration : NamedAstNode
    {
		public Modifiers Modifiers { get; set; }
        public Expression Initializer { get; set; }

        public FieldDeclaration(string name) : base (name)
        {
        }

        public override void AcceptVisitor<C>(IAstNodeVisitor<C> visitor, C ctx)
        {
            visitor.VisitFieldDeclaration(this, ctx);
        }

		internal CheckExpressionResult CheckInitializer()
		{
			if (Initializer != null)
			{
				if (!CompatibleTypes(COMPATIBLES, this.Type.SystemType, Initializer.Type.SystemType))
					return CheckExpressionResult.RIGHT;
			}
			return CheckExpressionResult.OK;
		}
	}
}
